﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace com.sharepointutils.application
{
    public partial class ConditionControl : UserControl
    {
        public String Filter { get { return combo_type.Text; } set { combo_type.Text = value; } }
        public List<KeyValuePair<String, String>> Fields { set { combo_column.DataSource = value; } }
        public event EventHandler<FilterEventArgs> FilterChanged;

        public ConditionControl()
        {
            InitializeComponent();
            combo_type.SelectedIndex = 0;
        }

        public ConditionControl(List<KeyValuePair<String, String>> fields)
        {
            InitializeComponent();
            combo_type.SelectedIndex = 0;
            this.Fields = fields;
        }

        private void combo_type_SelectedIndexChanged(object sender, EventArgs e)
        {

            if (this.FilterChanged != null)
            {
                EventArgs ee = new EventArgs();
                this.FilterChanged(sender, new FilterEventArgs(combo_type.Text));
            }
        }
    }

    public class FilterEventArgs : EventArgs
    {
        public String Value { get; set; }

        public FilterEventArgs(String value)
        {
            this.Value = value;
        }

        public FilterEventArgs()
        {}
    }
}
